<?php

require_once('resources/class/private/webos.php');

$webos = new webosClass();

$app_menu_list = $webos -> get_plugin_menu('set');

while ($dr = mysql_fetch_array($app_menu_list)) {
	
	if ($dr['pmParentID'] == 0) {
		
		if (!empty($menu)) {
			
			$menu .= '</div>';
		
			if ($group != $dr['pmGroup']) {
				
				$menu .= '<div class="menu-class group"></div>';
				
			}
			
		}
		
		$group = $dr['pmGroup'];
		
		$menu .= '<div class="menu-class parent" menutype="' . $dr['pmType'] . '" key="' . $dr['webosPluginMenuID'] . '" name="' . $dr['pmName'] . '">' . $dr['pmName'] . '<a href="javascript:;" onclick="setClass(' . $dr['webosPluginMenuID'] . ', \'update\');">修改</a><a href="javascript:;" onclick="setClass(' . $dr['webosPluginMenuID'] . ', \'insert\');">添加</a><a href="javascript:;" onclick="setClassDelete(' . $dr['webosPluginMenuID'] . ');">删除</a>';
		
	} else {
	
		$menu .= '<div class="menu-class child" menutype="' . $dr['pmType'] . '" key="' . $dr['webosPluginMenuID'] . '" name="' . $dr['pmName'] . '">' . $dr['pmName'] . '<a href="javascript:;" onclick="setClass(' . $dr['webosPluginMenuID'] . ', \'update\');">修改</a><a href="javascript:;" onclick="setClassDelete(' . $dr['webosPluginMenuID'] . ');">删除</a></div>';
	
	}
	
}

$menu .= '</add>';

$windowID = Jpublic::get('webosWindowID');

?>
<script>

	var setClass = function (id, type) {
		
		if (type == 'update') {
			
			title = '修改类别';
			
		} else {
		
			title = '添加类别';
		
		}
		
		layer.layer({
			
			title: title,
			
			id: 'application-menu-class-add',
			
			width: '460px',
			
			height: '350px'
			
		}, '<?php echo JSACTION;?>?action=admin&mod=set-application-class&operation=' + type + '&id=' + id + '&parentWindowID=<?php echo $windowID;?>');
		
	}

	var setClassDelete = function (id) {
		
		layer.del(function () {
		
			location.href = '<?php echo JSACTION;?>?action=admin&mod=set-application-class/delete-class&id=' + id + '&formhash=<?php echo JAdmin_core::formHASH();?>';
		
		}, '删除后此类别的应用不会删除，确认删除吗？');
		
	}

</script>
<style>
.menu-class {
	font-size: 14px;
	cursor: pointer;
	font-weight: bold;
	font-family: '微软雅黑';
	padding: 5px;
}
.group {
	padding: 0;
	border-top: solid 1px #666;
}
.menu-class:hover {
	background: #dfdfdf;
}
.child {
	padding: 5px 0 5px 20px;
}
.child:hover {
	background: #ccc;
}
.child:hover a {
	display: inline;
}
.parent:hover a {
	display: inline;
}
.menu-class a {
	color: #000;
	font-weight: 100;
	padding-left: 10px;
	font-size: 12px;
	display: none;
	line-height: normal;
}
.menu-class a:hover {
	color: #f00;
}
</style>
<div class="table-div">
	<table cellpadding="5" style="width:100%;">
		<tr>
			<td>
				<?php echo $menu;?>
			</td>
		</tr>
		<tr>
			<td><button type="button" onclick="setClass(0, 'insert');" class="button">添加类别</button></td>
		</tr>
	</table>
</div>